package com.jmp.security.grant;

import com.jmp.security.base.ClientDetail;
import com.jmp.security.base.RequestDetail;
import com.jmp.security.base.UserDetail;
import one.stand.advice.ResultEnum;
import one.stand.mapper.CompanyMapperExt;
import one.stand.service.BusinessCardBaseService;
import one.stand.util.AssertUtil;

public class EquCardUserDetailValidServiceImpl<T extends RequestDetail> extends CardUserDetailValidServiceImpl<T> {
    public EquCardUserDetailValidServiceImpl(BusinessCardBaseService businessCardBaseService, CompanyMapperExt companyMapperExt) {
        super(businessCardBaseService, companyMapperExt);
    }

    @Override
    public void check(T requestDetail, ClientDetail clientDetail, UserDetail userDetail) {
        super.check(requestDetail, clientDetail, userDetail);

        AssertUtil.isTrue(userDetail.getCardModel().getCompanyId().equals(clientDetail.getCompanyId()),
                ResultEnum.NO_TOURIST,
                "用户【" + userDetail.getCardModel().getName() + "】不是" + userDetail.getCompany() + "企业成员，没有权限登录");
    }
}
